package com.lb.shopguide.adapter;

import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import com.blankj.utilcode.util.ScreenUtils;
import com.blankj.utilcode.util.SizeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lb.shopguide.R;
import com.lb.shopguide.util.pic.ImageLoaderUtils;

import java.util.List;

/**
 * Create by kangzhao on 2018/11/25
 */
public class AdapterGoodsGallery extends BaseQuickAdapter<String, BaseViewHolder> {
    public AdapterGoodsGallery(int layoutResId, @Nullable List<String> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        View view = helper.itemView;
        int width = Math.round((ScreenUtils.getScreenWidth() - SizeUtils.dp2px(53)) / 3);
        int height = width;
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams();
        params.width = width;
        params.height = height;
        view.setLayoutParams(params);
        ImageView imageView = view.findViewById(R.id.iv_goods);
        ImageLoaderUtils.display(mContext, imageView, item);
    }
}
